package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.InvoiceTotalInfo;

public interface InvoiceTotalInfoRepository extends JpaRepository<InvoiceTotalInfo, String> {

	@Query("select i from InvoiceTotalInfo i where (i.sInvoiceName like '%'+?1+'%' or i.sInvoiceCustomerName like '%'+?1+'%' or i.sInvoiceTradeType like '%'+?1+'%' " + 
			" or i.sInvoiceCustomerAccount like '%'+?1+'%' or i.sInvoiceIdentifyType like '%'+?1+'%' or i.sInvoiceAccount like '%'+?1+'%') ")//i. like '%'+?1+'%'
	Page<InvoiceTotalInfo> findAllBykey(String key, Pageable pageable);

	@Query("select count(*) from InvoiceTotalInfo i where (i.sInvoiceName like '%'+?1+'%' or i.sInvoiceCustomerName like '%'+?1+'%' or i.sInvoiceTradeType like '%'+?1+'%' " + 
			" or i.sInvoiceCustomerAccount like '%'+?1+'%' or i.sInvoiceIdentifyType like '%'+?1+'%' or i.sInvoiceAccount like '%'+?1+'%') ")//i. like '%'+?1+'%'
	long findAllBykeyCount(String key);

	@Query("select i from InvoiceTotalInfo i where i.cController is not null ")//i. like '%'+?1+'%'
	List<InvoiceTotalInfo> findByCController();

}
